package com.das.mechanic_base.mvp.presenter.finish;

import com.das.mechanic_base.base.X3BasePresenter;
import com.das.mechanic_base.mapi.api.NetWorkHttp;
import com.das.mechanic_base.mapi.response.HttpCallBack;
import com.das.mechanic_base.mapi.schedulers.RxSchedulersHelper;
import com.das.mechanic_base.mvp.contract.finish.AloneFinishContract;

public class X3AloneFinishPresenter extends X3BasePresenter<AloneFinishContract.View> implements AloneFinishContract.Presenter{

    @Override
    public void requestWorkBaseReportStatus(long workBaseId) {

        NetWorkHttp.getApi().getWorkBaseReportStatus(workBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<Boolean>() {
                    @Override
                    protected void onDone(Boolean aBoolean) {
                        mView.getWorkBaseReportStatus(aBoolean);
                    }

                    @Override
                    protected String LoadingMessage() {
                        return null;
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });
    }

    @Override
    public void openReportOnHub(long workBaseId) {

        NetWorkHttp.getApi().openReportOnHub(workBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<Object>() {
                    @Override
                    protected void onDone(Object o) {
                        mView.openReportOnHubSuccess();
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });
    }

    @Override
    public void getOpenReportStatus(long workBaseId) {
        NetWorkHttp.getApi().getOpenReportStatus(workBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<Integer>() {
                    @Override
                    protected void onDone(Integer o) {
                        mView.getOpenReportStatusSuccess(o);
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });
    }

    @Override
    public void recordingScreenOnHub(long workBaseId) {

        NetWorkHttp.getApi().recordingScreenOnHub(workBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<Object>() {
                    @Override
                    protected void onDone(Object o) {
                        mView.recordingScreenOnHubSuccess();
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });

    }

    @Override
    public void getRecordingScreenStatus(long workBaseId) {
        NetWorkHttp.getApi().getRecordingScreenStatus(workBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<Integer>() {
                    @Override
                    protected void onDone(Integer status) {
                        mView.getRecordingScreenStatusSuccess(status);
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });
    }
}
